package com.restaurant.springboot.controller;

import com.restaurant.springboot.entity.CouponSeriesEntity;
import com.restaurant.springboot.entity.dto.CouponSeriesDTO;
import com.restaurant.springboot.service.CouponSeriseService;
import com.restaurant.springboot.utils.RespCode;
import com.restaurant.springboot.utils.RespEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/admin/couponSeries")
public class AdminCouponSeriesController {

    @Autowired
    private CouponSeriseService couponSeriseService;


    //此处为假删除，enable设置为false
    @DeleteMapping("")
    public RespEntity deleteCouponSeries(@RequestBody CouponSeriesEntity couponSeries){
        couponSeriseService.deleteCouponSeries(couponSeries);
        return new RespEntity(RespCode.SUCCESS,"delete success",null);
    }

    @PostMapping("")
    public RespEntity addCouponSeries(@RequestBody CouponSeriesDTO couponSeriesDTO){
        if(couponSeriseService.insertCouponSeries(couponSeriesDTO)){
            return new RespEntity(RespCode.SUCCESS,"add success" ,null);
        }
        return new RespEntity(RespCode.ERROR,"add fail",null);
    }



}
